package cn.lintcode;

import java.io.*;
import java.util.Arrays;
import java.util.Scanner;

/**
 * @author labvi
 * @version 1.0.0
 */
public class LargestNumber {
    private final static PrintWriter out = new PrintWriter(System.out);
    private final static BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
    private final static StreamTokenizer scanner = new StreamTokenizer(bufferedReader);
    public static String largestNum(String[] nums){
        String res = String.join("", Arrays.stream(nums)
                .sorted((b,a)->(a+b).compareTo(b+a))
                .toArray(String[]::new));
        return res.charAt(0) == '0'?"0":res;
    }

    private static String largestNum2(String[] nums){
        Arrays.sort(nums, new NumbersComparator());
        StringBuilder sb = new StringBuilder();
        for (String num : nums) {
            sb.append(num);
        }
        return sb.toString();
    }

    public static void main(String[] args) throws IOException {
        scanner.nextToken();
        int i = (int)scanner.nval;
        String[] list = new String[i];
        for (int j = 0; j < i; j++) {
            scanner.nextToken();
            list[j] = String.valueOf((int)scanner.nval);
        }
        out.println(largestNum(list));
        out.flush();
    }
}

